package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsPageDto;
import com.heima.wemedia.service.WmStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("api/v1/statistics")
public class WmStatisticsController {

    @Autowired
    private WmStatisticsService wmStatisticsService;

    /**
     * 统计数字
     * @param beginDate
     * @param endDate
     * @return
     */
    @GetMapping("newsDimension")
    public ResponseResult newsDimension(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginDate, @DateTimeFormat(pattern = "yyyy-MM-dd")Date endDate){
        return wmStatisticsService.newsDimension(beginDate,endDate);
    }

    /**
     * 分页展示
     * @return
     */
    @GetMapping("newsPage")
    public ResponseResult newsPage(WmNewsPageDto dto){
        return wmStatisticsService.newsPage(dto);
    }


}
